#include<bits/stdc++.h>

using namespace std;
typedef long long ll;
char graph[10][10] = {
        {'A', 'B', 'C', 'D'},
        {'E', 'F', 'G', 'H'},
        {'I', 'J', 'K', '/'},
        {'M', 'N', '/', 'P'},

};
int sx = 0, sy = 0;//起点的坐标
int book[10][10];//book[i][j]=1 代表地图上map[i][j]已经访问过
int n = 4;
int fx[4][2] = {0, 1, 1, 0, 0, -1, -1, 0};
int data[10 * 10][2], head = 0, tail = -1;//队列数据结构

void bfs(int sx, int sy) {
    ++tail;
    data[tail][0] = sx;
    data[tail][1] = sy;
    book[sx][sy] = 1;//入队标记
    while (head <= tail) {
        int hx = data[head][0], hy = data[head][1];//访问头结点
        cout << graph[hx][hy] << " ";
        ++head;//头结点出队
        for (int i = 0; i < 4; i++) {
            int nx = hx + fx[i][0];
            int ny = hy + fx[i][1];
            if (nx < 0 || nx >= n || ny < 0 || ny >= n || book[nx][ny] == 1 || graph[nx][ny] == '/')continue;
            ++tail;
            data[tail][0] = nx;
            data[tail][1] = ny;
            book[nx][ny] = 1;//入队标记
        }
    }
}

int main() {
    bfs(0, 0);
    return 0;
}